package com.veeder.datacollection.rs232.response;

import java.util.Date;

import org.apache.commons.csv.CSVRecord;


import com.veeder.datacollection.fileHandler.CSVStorable;
import com.veeder.datacollection.util.DateUtil;

public class BasicTankInventory implements CSVStorable{
	
	public final static String[] File_HEADERS = { "TankID", "SampleTime", "Inventory", "TotalHeight", "WaterHeight",
			"WaterVolume", "AvgTemp" };

	private int tankNo;
	private Date sampleTime;
	private String productCode;
	private String tankStatus;
	private float volume;
	private float tcVolume;
	private float ullage;
	private float height;
	private float waterHeight;
	private float waterVolume;
	private float temperature;
	
	
	public BasicTankInventory(){
		
	}
	
	public BasicTankInventory(CSVRecord r) throws Exception{
		int i=0;
		try {
			this.tankNo=Integer.parseInt(r.get(File_HEADERS[i++]));
			this.sampleTime=DateUtil.convertToDate(r.get(File_HEADERS[i++]), DateUtil.DateFormat3);
			this.volume=Float.parseFloat(r.get(File_HEADERS[i++]));
			this.height=Float.parseFloat(r.get(File_HEADERS[i++]));
			this.waterHeight=Float.parseFloat(r.get(File_HEADERS[i++]));
			this.waterVolume=Float.parseFloat(r.get(File_HEADERS[i++]));
			this.temperature=Float.parseFloat(r.get(File_HEADERS[i++]));	
		} catch (Exception e) {
			throw new Exception(e.toString());
		}
	}

	public float getVolume() {
		return volume;
	}

	public void setVolume(float volume) {
		this.volume = volume;
	}

	public float getHeight() {
		return height;
	}

	public void setHeight(float height) {
		this.height = height;
	}

	public float getWaterHeight() {
		return waterHeight;
	}

	public void setWaterHeight(float waterHeight) {
		this.waterHeight = waterHeight;
	}

	public float getWaterVolume() {
		return waterVolume;
	}

	public void setWaterVolume(float waterVolume) {
		this.waterVolume = waterVolume;
	}

	public float getTemperature() {
		return temperature;
	}

	public void setTemperature(float temperature) {
		this.temperature = temperature;
	}

	public int getTankNo() {
		return tankNo;
	}

	public void setTankNo(int tankNo) {
		this.tankNo = tankNo;
	}
	
	public Date getSampleTime() {
		return sampleTime;
	}

	public void setSampleTime(Date sampleTime) {
		this.sampleTime = sampleTime;
	}
		
	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

	public String getTankStatus() {
		return tankStatus;
	}

	public void setTankStatus(String tankStatus) {
		this.tankStatus = tankStatus;
	}

	public float getTcVolume() {
		return tcVolume;
	}

	public void setTcVolume(float tcVolume) {
		this.tcVolume = tcVolume;
	}

	public float getUllage() {
		return ullage;
	}

	public void setUllage(float ullage) {
		this.ullage = ullage;
	}

	
	public String toString(){
		return String.format("%d,%s,%.2f,%.2f,%.2f,%.2f,%.2f", tankNo,DateUtil.formatDate(sampleTime, DateUtil.DateFormat3),
				volume,height,waterHeight,waterVolume,temperature);
	}

	
	@Override
	public String[] toStringArray() {
		return toString().split(",");
	}	
	
}
